import * as actionTypes from './actionTypes'
import axios from 'axios';

// 展开搜索框
export const openSearchOverlay = () => ({
  type: actionTypes.OPEN_SEARCH_OVERLAY
})

// 关闭搜索框
export const closeSearchOverlay = () => ({
  type: actionTypes.CLOSE_SEARCH_OVERLAY
})

// 获取搜索热门标签
export const getSearchTagList = () => {
  return (dispatch) => {
    axios.get('http://localhost:3000/search/hot').then(res => {
      const tags = res.data.result.hots
      const action = {
        type: actionTypes.GET_SEARCH_TAGS,
        tags
      }
      dispatch(action)
    })
  }
}